import logging
import os
import json
import colorlog

LOG_FILE = os.path.join(os.path.split(os.path.realpath(__file__))[0], './run.log')
log_colors_config = {
    'DEBUG': 'cyan',
    'INFO': 'green',
    'WARNING': 'yellow',
    'ERROR': 'red',
    'CRITICAL': 'red',
}

formatter = colorlog.ColoredFormatter(
    '%(log_color)s%(asctime)s [%(threadName)s] %(levelname)s (%(filename)s:%(lineno)d) - %(funcName)s(): %(message)s',
    log_colors=log_colors_config)

handler = logging.FileHandler(LOG_FILE)
handler.setLevel(logging.DEBUG)
handler.setFormatter(formatter)
# handler.setFormatter(logging.Formatter(format))

steam_handler = logging.StreamHandler()
steam_handler.setLevel(logging.DEBUG)
steam_handler.setFormatter(formatter)

logging.basicConfig(level=logging.DEBUG, handlers=[handler, steam_handler])
logger = logging.getLogger(__name__)
# logger.addHandler(steam_handler)
# logger.addHandler(handler)


if __name__ == '__main__':
    logger.info("----------")
    logger.error("----------")
    logger.debug("----------")